@extends('common')
@section('content')
    <form class="form-inline definewidth m20" action="index.html" method="get">
        年份：<select name="" id="" style="width: 100px;">
            <option value="">*请选择*</option></select>
        月份：<select name="" id="" style="width: 100px;">
            <option value="">*请选择*</option></select>
        职位：<select name="" id="" style="width: 100px;">
            <option value="">*请选择*</option></select>
        请假时间：<input type="text" name="" id="dateinfo"  placeholder="" value="">
        销假时间：<input type="text" name="" id="dateinfo1"  placeholder="" value="">
        <button type="submit" class="btn btn-primary">查询</button>
        <button type="button" class="btn btn-success">导出</button>\
    </form>
    <table class="table table-bordered table-hover definewidth m10">
        <thead>
        <tr>
            <th>员工姓名</th>
            <th>员工编号</th>
            <th>请假时间</th>
            <th>销假时间</th>
            <th>请假类型</th>
            <th>请假天数</th>
            <th>请假原因</th>
            <th>状态</th>
        </tr>
        </thead>
        @foreach($leave as $l)
        <tr>
            <td>{{$l->use_num}}</td>
            <td>{{$l->use_name}}</td>
            <td>{{$l->lea_start}}</td>
            <td>{{$l->lea_end}}</td>
            <td>{{$l->lea_type}}</td>
            <td>{{$l->lea_day}}</td>
            <td>{{$l->lea_reason}}</td>
            <td  idval="{{$l->lea_id}}">@if($l->lea_state!=1){!! "<div><a href='javescript:;' title='正在处理，请稍等...'><font color='red'>审核中</font></a>~待~<a href='javescript:;' class='approval'>批准</a></div>" !!}@else{!! "<a href='javescript:;'>已批准</a>" !!} @endif</td>
        </tr>
        @endforeach
    </table>
    <script src="{{url('api/jedate/jedate.js')}}"></script>
    <script type="text/javascript">
            $(function(){
                $(document).on('click','.approval',function(){
                    that=$(this)
                    if(confirm('您确定执行操作吗？')){
                        id=that.parent().parent().attr('idval');
                        $.get('{{url('human/leave')}}',{id:id,type:1},function(data){
                          if(data==1){
                                that.parent().html("<a href='javescript:;'>已批准</a>");
                            }else{
                                alert('您权限不够')
                            }
                        })
                    }
                })
            })
            jeDate({
                dateCell:"#dateinfo",
                format:"YYYY年MM月DD日 hh:mm:ss",
                isinitVal:true,
                isTime:true, //isClear:false,
                minDate:"2014-09-19 00:00:00",
                okfun:function(val){alert(val)}
            })
            jeDate({
                dateCell:"#dateinfo1",
                format:"YYYY年MM月DD日 hh:mm:ss",
                isinitVal:true,
                isTime:true, //isClear:false,
                minDate:"2014-09-19 00:00:00",
                okfun:function(val){alert(val)}
            })
    </script>
@stop